package org.an.proj.contacts;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import com.lzy.imagepicker.ImagePicker;
import org.an.proj.contacts.config.LogUtil;
import photo.PicassoImageLoader;

/**
 * 创建时间：2016年10月13日18:40 <br>
 * 作者：fuchaoyang <br>
 * 描述：每个进程在创建都会创建一个Application，所以我们如果有多个进程，就要在初始化的时候做判断，防止多次初始化
 */
public class MyApplication extends Application {
  private static final String TAG = "MyApplication";
  private static MyApplication mInstance;
  private Handler mHandler;

  public MyApplication() {
  }

  public static MyApplication getInstance() {
    return mInstance;
  }

  @Override protected void attachBaseContext(Context base) {
    LogUtil.e(TAG, "attachBaseContext");
    super.attachBaseContext(base);
  }

  @Override public void onCreate() {
    super.onCreate();
    mInstance = this;
    mHandler = new Handler();

    ImagePicker.getInstance().setImageLoader(new PicassoImageLoader());
  }

  public Handler getHandler() {
    return mHandler;
  }
}
